﻿<%@ Page Language="C#" ValidateRequest="false" EnableEventValidation="false" AutoEventWireup="true" 
    CodeFile="AddOrEdit.aspx.cs" Inherits="admin_Modules_NewsEvent_News_AddOrEdit" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="/admin/resources/css/base.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        .custom-trigger { background-image: url(/files/images/custom-trigger.gif) !important; }
    </style>
    <script src="/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/ckfinder.js" type="text/javascript"></script>
    <script src="/plugins/ckfinder/config.js" type="text/javascript"></script>
    <script src="/plugins/ckeditor/config.js" type="text/javascript"></script>
    <script src="/admin/resources/js/base.js" type="text/javascript"></script>
    <script type="text/javascript">

        //FCKEditor Js API
        var getFckText = function () {
            return CKEDITOR.instances.fckHtmlEditor.getData();
        }

        function BrowseServer() {
            // You can use the "CKFinder" class to render CKFinder in a page:
            var finder = new CKFinder();
            finder.basePath = '/plugins/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
            finder.selectActionFunction = SetFileField;
            finder.popup();
        }

        // This is a sample function which is called when a file is selected in CKFinder.
        function SetFileField(fileUrl) {
            triggerFilm.setValue(fileUrl);
            // document.getElementById('xFilePath').value = fileUrl;
        }


        function loadEditor() {
            var oFCKeditor = CKEDITOR.replace('fckHtmlEditor', {
                customConfig: '/plugins/ckeditor/config.js',
                filebrowserBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserImageBrowseUrl: '/plugins/ckfinder/ckfinder.html',
                filebrowserFlashBrowseUrl: '/plugins/ckfinder/ckfinder.html?type=Flash',
                filebrowserUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files',
                filebrowserImageUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
                filebrowserFlashUploadUrl: '/plugins/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'

            });

            oFCKeditor.BasePath = '/plugins/ckeditor/';
            oFCKeditor.Width = '680px';
            oFCKeditor.Skin = 'v2';
            oFCKeditor.Height = '250px';

            //CKFinder.setupCKEditor(oFCKeditor, { basePath: '/ckfinder/', rememberLastFolder: false });

        }

        var confirmDelete = function () {
            Ext.Msg.confirm('Xác nhận', '<span style="color:red;">Xóa tin bài?</span>', function (btn) {
                if (btn == "yes") {
                    //return true;
                    btnDoDelete.fireEvent('click', null);
                }
            });
            return false;
        }

        function setHtml(html) {
            return CKEDITOR.instances.fckHtmlEditor.setData(html);
        }

        function loadNewsCategory() {
            var url = "/admin/modules/newsevent/dialog/NewsCategoryList.aspx?cbFX=setValue&tId=" + getTabPanelID() + "&cateID=" + hdfParentCategoryID.getValue();
            window.top.createWindow('newsCategoryList', url, 'Chuyên mục tin tức', 560, 480, true);
        }

        var setValue = function (text, value) {
            //            alert(text + value);
            txtCategory.setValue(text);
            hdfParentCategoryID.setValue(value);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ScriptManager2" runat="server">
        <Listeners>
            <DocumentReady Handler="loadEditor();" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Viewport ID="ViewPort1" runat="server">
        <Items>
            <ext:BorderLayout ID="BorderLayout1" runat="server">
                <Center>
                    <ext:Panel ID="Panel12" runat="server" Title="Center" Header="false" AutoScroll="true"
                        BodyBorder="true" Border="true" BodyStyle="background-color:#fff; ">
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:Button Icon="Disk" Text="Tạo mới" runat="server" ID="btnAdd">
                                        <DirectEvents>
                                            <Click OnEvent="OnSave" Before="valid = #{StatusForm}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                                <ExtraParams>
                                                    <ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />
                                                    <ext:Parameter Name="mode" Mode="Value" Value="add" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:Button Text="Cập nhật" Icon="Disk" runat="server" ID="btnUpdate">
                                        <DirectEvents>
                                            <Click OnEvent="OnSave" Before="valid = #{StatusForm}.getForm().isValid(); if(valid){ Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving'); } return valid;">
                                                <ExtraParams>
                                                    <ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />
                                                    <ext:Parameter Name="mode" Mode="Value" Value="edit" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:ToolbarSpacer>
                                    </ext:ToolbarSpacer>
                                    <ext:Button Text="Xóa" Icon="Delete" ID="btnDelete">
                                        <Listeners>
                                            <Click Handler=" confirmDelete();"></Click>
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button Hidden="true" ID="btnDoDelete" runat="server">
                                        <DirectEvents>
                                            <Click OnEvent="OnSave" Before=" Ext.Msg.wait('Đang cập nhật dữ liêu...', 'Saving');">
                                                <ExtraParams>
                                                    <%--<ext:Parameter Name="fckParameter" Mode="Raw" Value="getFckText()" />--%>
                                                    <ext:Parameter Name="mode" Mode="Value" Value="delete" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <Items>
                            <ext:FormPanel runat="server" Border="false" ID="StatusForm" Padding="10">
                                <Items>
                                    <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="120">
                                        <Anchors>
                                            <ext:Anchor>
                                                <ext:TextField ID="txtTitle" runat="server" FieldLabel="Tiêu đề" Width="500" AllowBlank="false"
                                                    EmptyText="Tiêu đề tin">
                                                </ext:TextField>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TriggerField ID="txtCategory" runat="server" FieldLabel="Menu tin bài" AllowBlank="false"
                                                    Editable="false" Width="500" EmptyText="Chọn menu tin bài">
                                                    <Listeners>
                                                        <TriggerClick Handler="loadNewsCategory();" />
                                                        <Focus Handler="loadNewsCategory();" />
                                                    </Listeners>
                                                    <Triggers>
                                                        <ext:FieldTrigger Icon="Ellipsis" />
                                                    </Triggers>
                                                </ext:TriggerField>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfParentCategoryID" runat="server" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfCategoryId" runat="server" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfCategoryIDTemp" runat="server" Text="" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfCategoryTextTemp" runat="server" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TriggerField ID="triggerFilm" FieldLabel="Ảnh tỏm tắt" runat="server" Width="500"
                                                    Note="Nếu không có sẽ lấy trong nội dung tin bài" EmptyText="Ảnh tóm tắt" AllowBlank="true"
                                                    Editable="false">
                                                    <Listeners>
                                                        <TriggerClick Handler="BrowseServer();" />
                                                        <Focus Handler="BrowseServer();" />
                                                    </Listeners>
                                                    <Triggers>
                                                        <ext:FieldTrigger Icon="Ellipsis" />
                                                    </Triggers>
                                                </ext:TriggerField>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TextArea ID="txtShortContent" Name="txtShortContent" runat="server" FieldLabel="Nội dung tóm tắt"
                                                    EmptyText="Nội dung tóm tắt" Width="500" Height="70">
                                                </ext:TextArea>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TextArea ID="fckHtmlEditor" Name="fckHtmlEditor" runat="server" FieldLabel="Nội dung">
                                                </ext:TextArea>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfShortContent" runat="server" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:Hidden ID="hdfContent" runat="server" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:CheckboxGroup ID="chkg" runat="server" FieldLabel="Tính chất">
                                                    <Items>
                                                        <ext:Checkbox BoxLabel="Hiển thị" ID="chkIsActive" runat="server" Checked="true">
                                                        </ext:Checkbox>
                                                        <ext:Checkbox BoxLabel="Hiển thị ở Slide trên" ID="chkIsOnTop" runat="server" Visible="false">
                                                        </ext:Checkbox>
                                                        <ext:Checkbox BoxLabel="Hiển thị ở Slide dưới" ID="chkInSlideShow" runat="server"
                                                            Visible="false">
                                                        </ext:Checkbox>
                                                        <ext:Checkbox BoxLabel="Tin nổi bật" ID="chkIsHotInSite" runat="server" Checked="false"
                                                            Visible="true">
                                                        </ext:Checkbox>
                                                    </Items>
                                                </ext:CheckboxGroup>
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TextField ID="txtAuthor" runat="server" FieldLabel="Nguồn tin/ Tác gả" Width="500"
                                                    EmptyText="Nguồn tin hoặc tác giả" AllowBlank="true" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:TextField ID="txtLink" runat="server" FieldLabel="Liên kết" Width="500" EmptyText="Liên kết"
                                                    AllowBlank="true" />
                                            </ext:Anchor>
                                            <ext:Anchor>
                                                <ext:ComboBox ID="cbTarget" runat="server" SelectedIndex="0" FieldLabel="Kiểu bật cửa sổ">
                                                    <Items>
                                                        <ext:ListItem Text="Cửa sổ hiện tại" Value="_self" />
                                                        <ext:ListItem Text="Cửa sổ khác" Value="_blank" />
                                                    </Items>
                                                </ext:ComboBox>
                                            </ext:Anchor>
                                        </Anchors>
                                    </ext:FormLayout>
                                </Items>
                            </ext:FormPanel>
                        </Items>
                    </ext:Panel>
                </Center>
            </ext:BorderLayout>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
